/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import javax.persistence.*;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author simone
 */
@Entity
@Table(name = "Hotel")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Hotel.findAll", query = "SELECT h FROM Hotel h"),
    @NamedQuery(name = "Hotel.findByIdHotel", query = "SELECT h FROM Hotel h WHERE h.idHotel = :idHotel"),
    @NamedQuery(name = "Hotel.findByName", query = "SELECT h FROM Hotel h WHERE h.name = :name"),
    @NamedQuery(name = "Hotel.findByAddress", query = "SELECT h FROM Hotel h WHERE h.address = :address"),
    @NamedQuery(name = "Hotel.findByRating", query = "SELECT h FROM Hotel h WHERE h.rating = :rating"),
    @NamedQuery(name = "Hotel.findByCost", query = "SELECT h FROM Hotel h WHERE h.cost = :cost")})
public class Hotel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_hotel")
    private Integer idHotel;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "address")
    private String address;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "rating")
    private int rating;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cost")
    private double cost;
    @OneToMany(mappedBy = "fkHotel")
    private Collection<Pacchettoprenotato> pacchettoprenotatoCollection;
    @JoinColumn(name = "fk_citta", referencedColumnName = "id_citta")
    @ManyToOne(optional = false)
    private Citta fkCitta;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "Comprende_prodotti",
            joinColumns = {@JoinColumn(name = "id_hotel", referencedColumnName = "id_hotel")},
            inverseJoinColumns = {@JoinColumn(name = "id_pacchetto", referencedColumnName = "id_pacchetto")})
    private List<Pacchetto>pacchettiOwnHotels;

    
    
    public Hotel() {
    }

    public Hotel(Integer idHotel) {
        this.idHotel = idHotel;
    }

    public Hotel(Integer idHotel, String name, String address, String description, int rating, double cost) {
        this.idHotel = idHotel;
        this.name = name;
        this.address = address;
        this.description = description;
        this.rating = rating;
        this.cost = cost;
    }

    public List<Pacchetto> getpacchettiOwnHotels()
    {
        return this.pacchettiOwnHotels;
    }
    
    
    public Integer getIdHotel() {
        return idHotel;
    }

    public void setIdHotel(Integer idHotel) {
        this.idHotel = idHotel;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    @XmlTransient
    public Collection<Pacchettoprenotato> getPacchettoprenotatoCollection() {
        return pacchettoprenotatoCollection;
    }

    public void setPacchettoprenotatoCollection(Collection<Pacchettoprenotato> pacchettoprenotatoCollection) {
        this.pacchettoprenotatoCollection = pacchettoprenotatoCollection;
    }

    public Citta getFkCitta() {
        return fkCitta;
    }

    public void setFkCitta(Citta fkCitta) {
        this.fkCitta = fkCitta;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idHotel != null ? idHotel.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hotel)) {
            return false;
        }
        Hotel other = (Hotel) object;
        if ((this.idHotel == null && other.idHotel != null) || (this.idHotel != null && !this.idHotel.equals(other.idHotel))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.entities.Hotel[ idHotel=" + idHotel + " ]";
    }
    
}
